home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 18 / AMIGAplus Sonderheft 18 (1999)(ICP)(DE)[!].iso / Forum / MichaelRoth / 3-3-99 / code / code12.asm < prev    next >
Assembly Source File  |  1998-10-28  |  6KB  |  223 lines

  1. ;// Autor
  2. ;                            %
  3. ;                          %%*%%
  4. ;                        %%%* *%%%
  5. ;                      %%%%* B *%%%%
  6. ;                    %%%%%*  T  *%%%%%
  7. ;                  %%%%%%*   B   *%%%%%%
  8. ;                %%%%%%%*    1    *%%%%%%%
  9. ;              %%%%%%%%*     3     *%%%%%%%%
  10. ;          *%%%%%%%%%%*      M      *%%%%%%%%%%*
  11. ;        %%%%%%%%%%%%*---------------*%%%%%%%%%%%%
  12. ;       %%              A M I G A                %%
  13. ;      %%      B i l l y   T h e   B y t e        %%
  14. ;       %%        © 1997  Michael Roth           %%
  15. ;        %%%%%%%%%%%%*---------------*%%%%%%%%%%%%
  16. ;          *%%%%%%%%%%*      D      *%%%%%%%%%%*
  17. ;              %%%%%%%%*     A     *%%%%%%%%
  18. ;                %%%%%%%*    C    *%%%%%%%
  19. ;                  %%%%%%*   6   *%%%%%%
  20. ;                    %%%%%*  9  *%%%%%
  21. ;                      %%%%* 8 *%%%%
  22. ;                        %%%* *%%%
  23. ;                          %%*%%
  24. ;                            %
  25. ;\\
  26.  
  27. ;// Include
  28.           Include  assem:macro/Dir
  29.           Include  assem:macro/Exec.m
  30.           Include  assem:macro/Dos.m
  31.           Include  Dos/DosExtens.i
  32.           include  macro/filelength
  33. ;\\
  34.  
  35. ;// Libraries öffnen
  36.           OpenDos  37
  37. ;\\
  38.  
  39. ;//ReadArgs
  40.           move.l   #inputstr,d1                  ; Eingabe String
  41.           move.l   #arry,d2                      ; Arry
  42.           move.l   #0,d3                         ; Keine Externe Structur
  43.           Dos      ReadArgs                      ; Argumente Lesen
  44.           move.l   d0,rdargs                     ; speichern
  45.           bne.s    .1                            ; prüfen ob alles o.k.
  46.           error    cleanup,20                    ; o.k. >.1 Ansonsten Fehlermeldung beenden
  47. .1                                               ;
  48.           lea   arry,a0                          ; Arry nach a0
  49. ;\\
  50.  
  51. ;//File Öffnen und gröe bestimmen
  52.           move.l   (a0),d1
  53.           move.l   #MODE_OLDFILE,d2              ; 1005
  54.           Dos      Open                          ; File Öffnen
  55.           bne.s    .2
  56.           error    cleanup,20
  57. .2
  58.           move.l   d0,fh
  59.           filelength fh,filelänge                ; Filelänge bestimmen
  60. ;\\
  61.  
  62. ;// Speicher Reservieren
  63.          move.l    filelänge,d0
  64.          move.l    #MEMF_CLEAR,d1
  65.          Exec      AllocMem
  66.          move.l    d0,memblock
  67.          bne.s     .memallockok
  68.          error     cleanup,20
  69. .memallockok
  70. ;\\
  71.  
  72. ;// File einlesen
  73.          move.l   fh,d1
  74.          move.l   memblock,d2
  75.          move.l   filelänge,d3
  76.          Dos      Read
  77.          cmp.l    filelänge,d0
  78.          beq.s    .readok
  79.          error    cleanup,20
  80. .readok
  81. ;\\
  82.  
  83. key
  84. ;//File Öffnen und gröe bestimmen
  85.           lea      arry,a0                          ; Arry nach a0
  86.           move.l   8(a0),d1
  87.           move.l   #MODE_OLDFILE,d2              ; 1005
  88.           Dos      Open                          ; File Öffnen
  89.           bne.s    .2
  90.           error    cleanup,20
  91. .2
  92.           move.l   d0,fh2
  93.           filelength fh2,filelänge2                ; Filelänge bestimmen
  94. ;\\
  95.  
  96. ;// Speicher Reservieren
  97.          move.l    filelänge2,d0
  98.          move.l    #MEMF_CLEAR,d1
  99.          Exec      AllocMem
  100.          move.l    d0,memblock2
  101.          bne.s     .memallockok
  102.          error     cleanup,20
  103. .memallockok
  104. ;\\
  105.  
  106. ;// File einlesen
  107.          move.l   fh2,d1
  108.          move.l   memblock2,d2
  109.          move.l   filelänge2,d3
  110.          Dos      Read
  111.          cmp.l    filelänge2,d0
  112.          beq.s    .readok
  113.          error    cleanup,20
  114. .readok
  115. ;\\
  116.  
  117. code
  118. ;// Codieren
  119. ******************************************************************
  120.          move.l   memblock,a0                          ; Startadresse des Klartextes
  121.          move.l   memblock2,a1                         ; "" des Keys
  122.          move.l   filelänge,d0                   ; Länge des Buffers
  123.          move.l   filelänge2,d1                  ; Länge des Keys
  124.          lea      (a0,d0),a2                     ; Endadresse des Buffers berechnen
  125.          lea      (a1,d1),a3                     ; """" des Keys
  126. .loop1
  127.          move.b   (a1)+,d4
  128.          move.b   (a0),d0
  129.         rol.b    #4,d4
  130.          eor.b    d4,d0
  131. ;         not.b    d0
  132.          move.b   d0,(a0)+
  133.          cmp.l    a1,a3                           ; Prüfen ob Key am Ende
  134.          bhi.s    .ggoon                          ; wenn nein weiter
  135.          move.l   memblock2,a1                    ; ansonsten neu laden
  136. .ggoon                                            ;
  137.          cmp.l    a0,a2                           ; Prüfen ob Buffer am Ende
  138.          bhi.s    .loop1                          ; Nein -> nächste schleife
  139.  
  140.  
  141. ********************************************************************
  142. ;\\
  143.  
  144. ;// Zielfile Öffnen
  145.          lea       arry,a0                          ; Arry nach a0
  146.          move.l    4(a0),d1
  147.          move.l    #MODE_NEWFILE,d2
  148.          Dos       Open
  149.          move.l    d0,d7
  150.          bne       .ok
  151.          error     cleanup,20
  152. .ok
  153.  
  154.          move.l    d7,d1
  155.          move.l    memblock,d2
  156.          move.l    filelänge,d3
  157.          Dos       Write
  158.  
  159.          move.l    d7,d1
  160.          Dos       Close
  161. ;\\
  162.  
  163. ;// CleanUp
  164. cleanup
  165.           move.l   rdargs,d1
  166.           beq.s    .end                          ; Argumente da ?
  167.           Dos      FreeArgs                      ; Wenn Nein beenden
  168.  
  169.           move.l   fh,d1
  170.           beq.s    .1                            ; File geöffnet
  171.           Dos      Close                         ; Wenn nein weiter
  172. .1
  173.           move.l    memblock,d0
  174.           beq.s     .2
  175.           move.l    d0,a1
  176.           move.l    filelänge,d0
  177.           Exec      FreeMem
  178. .2
  179.           move.l   fh2,d1
  180.           beq.s    .3                            ; File geöffnet
  181.           Dos      Close                         ; Wenn nein weiter
  182. .3
  183.           move.l    memblock2,d0
  184.           beq.s     .4
  185.           move.l    d0,a1
  186.           move.l    filelänge2,d0
  187.           Exec      FreeMem
  188. .4
  189.  
  190.  
  191.  
  192. .end
  193.           closedos
  194.           moveq    #0,d0
  195.           rts
  196. ;\\
  197.  
  198. ;// Data
  199.  DATA
  200.  
  201. ver   dc.b "$VER: V0 - Written by DAC698 - Michael Roth",0
  202. inputstr
  203.          dc.b      "Source/A,Dest/A,Key/A",0 ;KeyFile/S",0
  204. cr
  205.          dc.b      10,0
  206.  
  207.  BSS
  208.  cnop 0,4
  209. arry     ds.l      3
  210. rdargs   ds.l      1
  211. fh       ds.l      1
  212. fh2      ds.l      1
  213. filelänge
  214.          ds.l      1
  215. memblock ds.l      1
  216. filelänge2
  217.          ds.l      1
  218. memblock2
  219.          ds.l      1
  220. insert   dc.b      4,0
  221. ;\\
  222.  
  223.